package com.deng.commons.utils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateUtils {

    /**
     * 返回当前日期其上一周日期
     * @return
     */
    public static List<String> getLastWeekDays(){
        List<String> days = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        for(int i=1;i<=7;i++){
            calendar.setTime(new Date());
            calendar.add(Calendar.DATE,-i);
            String date = sdf.format(calendar.getTime());
            days.add(date);
        }
        return days;
    }

    public static void main(String[] args) {
        System.out.println(getLastWeekDays());
    }

}
